{
  "cells": [
    {
      "cell_type": "markdown",
      "id": "468831db",
      "metadata": {
        "id": "468831db"
      },
      "source": [
        "# Phi-3.5 Mini Conversational Example"
      ]
    },
    {
      "cell_type": "markdown",
      "id": "ecb80fe2",
      "metadata": {
        "id": "ecb80fe2"
      },
      "source": [
        "**Description:**\n",
        "\n",
        "Demonstrates lightweight inference using Phi-3.5 Mini, suitable for smaller hardware and educational use cases."
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/DhivyaBharathy-web/PraisonAI/blob/main/examples/cookbooks/Phi_3_5_Mini_Conversational.ipynb)\n"
      ],
      "metadata": {
        "id": "S1erg7-JP6n3"
      },
      "id": "S1erg7-JP6n3"
    },
    {
      "cell_type": "markdown",
      "id": "0822161c",
      "metadata": {
        "id": "0822161c"
      },
      "source": [
        "**Dependencies**\n",
        "\n",
        "```python\n",
        "!pip install transformers accelerate\n",
        "!pip install torch\n",
        "```"
      ]
    },
    {
      "cell_type": "markdown",
      "id": "0df5580b",
      "metadata": {
        "id": "0df5580b"
      },
      "source": [
        "**Tools Used**\n",
        "\n",
        "- HuggingFace Transformers\n",
        "- PyTorch"
      ]
    },
    {
      "cell_type": "markdown",
      "id": "9d6df43d",
      "metadata": {
        "id": "9d6df43d"
      },
      "source": [
        "**YAML Prompt**\n",
        "\n",
        "```yaml\n",
        "system: You are a helpful assistant.\n",
        "user: Explain what an AI model is.\n",
        "```"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "id": "0e775593",
      "metadata": {
        "id": "0e775593"
      },
      "outputs": [],
      "source": [
        "from transformers import AutoTokenizer, AutoModelForCausalLM\n",
        "\n",
        "tokenizer = AutoTokenizer.from_pretrained(\"microsoft/phi-3.5-mini\")\n",
        "model = AutoModelForCausalLM.from_pretrained(\"microsoft/phi-3.5-mini\")\n",
        "\n",
        "inputs = tokenizer(\"What is an AI model?\", return_tensors=\"pt\")\n",
        "outputs = model.generate(**inputs, max_new_tokens=40)\n",
        "print(tokenizer.decode(outputs[0], skip_special_tokens=True))"
      ]
    },
    {
      "cell_type": "markdown",
      "id": "187fe354",
      "metadata": {
        "id": "187fe354"
      },
      "source": [
        "**Output**\n",
        "\n",
        "The model gives a basic explanation of what AI models do.\n",
        "\n",
        "What is an AI model?\n",
        "An AI model is a computer program that is trained on large amounts of data to perform tasks that normally require human intelligence.\n"
      ]
    }
  ],
  "metadata": {
    "colab": {
      "provenance": []
    }
  },
  "nbformat": 4,
  "nbformat_minor": 5
}